# -*- coding: utf-8 -*-
# @Time    : 2023/6/5 16:09
# @Author  : hyh
# @Email   : 935887145@qq.com
# @File    : edit_page.py
# @Software: PyCharm
from pages.base_page import BasePage
from appium import webdriver
from tools import driver
from appium.webdriver.common.mobileby import MobileBy as By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import  expected_conditions as EC

class EditPage(BasePage):
    picture_locator = (By.XPATH,'//*[@resource-id="com.xiachufang:id/rv_course_review"]/android.widget.FrameLayout[1]')
    more_locator = (By.XPATH,'//*[@resource-id="com.xiachufang:id/common_control_panel_more_btn"]')
    edit_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"android:id/text1\" and @text=\"编辑\"]')
    input_locaotor = (By.XPATH,'//android.widget.EditText[@resource-id=\"com.xiachufang:id/dish_desc\"]')
    label_locator = (By.XPATH,'//android.widget.TextView[@text=\"晚餐\"]')
    release_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/dish_update_image\"]')
    title_locator = (By.XPATH,'//android.widget.TextView[@resource-id=\"com.xiachufang:id/feed_dish_description_tv\"]')
    def click_picture(self):
        self.find_element(self.picture_locator).click() #点击作品内的图片
    def click_more(self):
        self.find_element(self.more_locator).click() #点击右上角三个点
    def click_edit(self):
        self.find_element(self.edit_locator).click() #点击编辑按钮
    def click_input(self):
        self.find_element(self.input_locaotor).click() #点击输入框
    def clear_input(self):
        self.find_element(self.input_locaotor).clear() #清空输入框
    def input(self,shuru):
        self.find_element(self.input_locaotor).send_keys(shuru) #输入内容
    def click_label(self):
        self.find_element(self.label_locator).click() #点击标签
    def click_release(self):
        self.find_element(self.release_locator).click() #点击发布
    def get_title(self):
        current_title = self.find_element(self.title_locator).get_attribute('text') #获取文本
        return current_title

